package com.example.zuoye;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RegisterActivity extends AppCompatActivity {

    private TextView tvUsername;
    private EditText etUsername;
    private TextView tvPassword;
    private EditText etPassword;
    private TextView tvSex;
    private EditText etSex;
    private TextView tvAge;
    private EditText etAge;
    private Button btnReg;
    private Button btnLogin;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        tvUsername = (TextView) findViewById(R.id.tv_username);
        etUsername = (EditText) findViewById(R.id.et_username);
        tvPassword = (TextView) findViewById(R.id.tv_password);
        etPassword = (EditText) findViewById(R.id.et_password);
        tvSex = (TextView) findViewById(R.id.tv_sex);
        etSex = (EditText) findViewById(R.id.et_sex);
        tvAge = (TextView) findViewById(R.id.tv_age);
        etAge = (EditText) findViewById(R.id.et_age);
        btnReg = (Button) findViewById(R.id.btn_reg);
        btnLogin = (Button) findViewById(R.id.btn_login);
    }

    public void submit(View view) {
        if(etUsername.getText().toString().length()>4){
            Intent intent=new Intent(this,LoginActivity.class);
            intent.putExtra("username",etUsername.getText().toString());
            intent.putExtra("password",etPassword.getText().toString());
            intent.putExtra("gender",etSex.getText().toString());
            intent.putExtra("age",etAge.getText().toString());
            setResult(Activity.RESULT_OK,intent);
            finish();
        }else {
            Toast.makeText(this,"请使用合法的用户名和密码",Toast.LENGTH_SHORT).show();
        }

    }
    public void cancel(View view){

        setResult(Activity.RESULT_CANCELED);
        finish();

    }
}